﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;

namespace MBS.UserControls.MovieUserControl
{
    public partial class AddMovieUserControl : System.Web.UI.UserControl
    {
        #region transfer

        MBSBLC.BLC movieblc = new MBSBLC.BLC();
        private bool actionresult;


        public delegate void MovieAddHandler();

        public event MovieAddHandler MovieAddComplete;
        public event MovieAddHandler MovieAddFailed;


        public bool Actionresult
        {
            get { return actionresult; }
            set { actionresult = value; }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                movieblc = new MBSBLC.BLC();
            }  

        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {

        }

        protected void releaseDateCalendar_SelectionChanged(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            actionresult = movieblc.AddMovie(txtMovieTitle.Text, txtDescription.Text, txtDuration.Text.ToString(), txtGenre.Text, txtCast.Text, txtRating.Text.ToString(), txtImageURL.Text, DateTime.Parse(ReleaseDateTextBox.Text, new CultureInfo("en-US")), txtTrailerURL.Text);

            if (actionresult) { MovieAddComplete(); }
            else
            {
                MovieAddFailed();
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            txtMovieTitle.Text = "";
            txtDescription.Text = "";
            txtDuration.Text = "";
            txtGenre.Text = "";
            txtCast.Text = "";
            txtRating.Text = "";
            txtImageURL.Text = "";
            ReleaseDateTextBox.Text = "";
            txtTrailerURL.Text = "";

        }

    }
        #endregion
}